package org.zy;

import org.zy.thread.FutureDemo;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @author Zhang Yu
 * @description: TODO
 * @date 2024/5/8 10:21
 */
public class FutureTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureDemo futureDemo = new FutureDemo();
        Future<Integer> futureOne  = futureDemo.calculate(20);
        while(!futureOne.isDone()) {
            System.out.println("Calculating...");
            Thread.sleep(300);
        }
        Integer integer = futureOne.get();
        System.out.println("integer = " + integer);
        futureDemo.executor.shutdown();
    }
}
